package com.homework;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(value = "/ServletLife",loadOnStartup = 1)
public class ServletLife extends HttpServlet {

    @Override
    public void init() throws ServletException {
        System.out.println("初始化成功~~正在连接");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("已启动");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    public void destroy() {
        //当服务停止时，或者服务器宕机时，对象消亡
        System.out.println("嗝屁了");
    }
}
